home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / DVDWorld (BR).ifs < prev    next >
Text File  |  2005-03-13  |  7KB  |  235 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=O Guardiπo (<link>bruno_mga@hotmail.com</link>)
  8. Title=DVD World
  9. Description=Movie importation script for DVD World
  10. Site=www.dvdworld.com.br
  11. Language=PT
  12. Version=1.2 (8 Fev 2005)
  13. Requires=3.5.0
  14. Comments=Script feito por O Guardiπo (bruno_mga@hotmail.com) para o site
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program dvdworld;
  23. const
  24.   BaseAddress = 'http://dvdworld.com.br/dvdworld.hts';
  25.   ManualPictureSelect = True;
  26.   ExternalPictures = False;
  27.   DescriptionToImport = 2;
  28. var
  29.   MovieName: string;
  30.   MovieURL: string;
  31. function HTMLRemove(Value: String): String;
  32. begin
  33.   HTMLDecode(Value);
  34.   HTMLRemoveTags(Value);
  35.   Value := Trim(Value);
  36.   result := Value;
  37. end;
  38.  
  39. function UpFirstLetterWord(texto:string):string; //Function Made By O Guardiπo
  40. var espaco:integer;
  41. sst:string;
  42. begin
  43. texto:=AnsiUpFirstLetter(AnsiLowerCase(texto));
  44. repeat
  45.     espaco:=Pos(' ',texto);
  46.     sst:=AnsiUpperCase(Copy(texto,espaco+1,1));
  47.     
  48. texto:=Copy(texto,1,espaco-1)+'/|\'+sst+Copy(texto,espaco+2,length(texto));
  49. until Pos(' ',texto)=0;
  50. texto := StringReplace(texto, '/|\', ' ');
  51. if Copy(texto,1,1)=' ' then
  52.   texto:=Copy(texto,2,length(texto));
  53. result:=texto;
  54. end;
  55.  
  56. procedure AnalyzeFilmPage(Address: String);
  57. var
  58.   Page : TStringList;
  59.   Line, Value : string;
  60.   LineNr, BeginPos, EndPos: Integer;
  61.   AllTitles: TStringList;
  62.   url_imdb:string;
  63.   nome_orig:string;
  64.   nome_trad:string;
  65.   pais:string;
  66.   genero:string;
  67.   realizac:string;
  68.   Interpretes:string;
  69.   descricao:string;
  70.   capa:string;
  71. begin
  72.   Page := TStringList.Create;
  73.   value := 'http://216.247.85.101/images/'+Address+'.jpg';
  74.   // (it is working well)
  75.   GetPicture(Value);
  76.   Address:='http://dvdworld.com.br/dvdworld.hts?+'+Address+'+acha';
  77.   Page.Text := GetPage(Address);
  78.   SetField(fieldURL, Address);
  79.  
  80.   LineNr := FindLine('Tφtulo Original:', Page, 0);
  81.   if LineNr<>-1 then
  82.   begin
  83.     Value := Page.GetString(LineNr);
  84.     BeginPos := pos('/b>',value);
  85.     EndPos := pos(' - ',value)-3;
  86.     nome_orig:=copy(value,BeginPos+3,EndPos-BeginPos);
  87.     nome_orig:=HTMLRemove(nome_orig);
  88.     SetField(fieldOriginalTitle, nome_orig);
  89.   end;
  90.  
  91.   LineNr := FindLine('<td  align="left" valign="top"><font face="Arial, Helvetica, sans-serif" size="4" color="#000066"><b>', Page, 0);
  92.   if LineNr<>-1 then
  93.   begin
  94.     Value := Page.GetString(LineNr);
  95.     nome_trad:=HTMLRemove(Value);
  96.     nome_trad:=UpFirstLetterWord(nome_trad);
  97.     SetField(fieldTranslatedTitle, nome_trad);
  98.   end;
  99.  
  100.   LineNr := FindLine('<b>Diretor:</b>', Page, 0);
  101.   if LineNr<>-1 then
  102.   begin
  103.     Value := Page.GetString(LineNr);
  104.     BeginPos := pos('/b>',value);
  105.     EndPos := pos('</f',value);
  106.     realizac:=copy(value,BeginPos+3,EndPos);
  107.     realizac:=HTMLRemove(realizac);
  108.     SetField(fieldDirector, realizac);
  109.   end;
  110.  
  111.   LineNr := FindLine('Atores: </b>', Page, 0);
  112.   if LineNr<>-1 then
  113.   begin
  114.     Value := Page.GetString(LineNr);
  115.     BeginPos := pos('/b>',value);
  116.     EndPos := pos('</f',value);
  117.     Interpretes:=copy(value,BeginPos+3,EndPos);
  118.     Interpretes:=HTMLRemove(Interpretes);
  119.     SetField(fieldActors, Interpretes);
  120.   end;
  121.  
  122.   LineNr := FindLine('GÊNERO', Page, 0)+4;
  123.   if LineNr<>4 then
  124.   begin
  125.     value:=HTMLRemove(Page.GetString(LineNr));
  126.     SetField(fieldCategory, value);
  127.   end;
  128.  
  129.   LineNr := FindLine('DE PRODUÇÃ', Page, 0)+4;
  130.   if LineNr<>4 then
  131.   begin
  132.     value:=HTMLRemove(Page.GetString(LineNr));
  133.     SetField(fieldYear, value);
  134.   end;
  135.  
  136.   LineNr := FindLine('DURAÇÃ', Page, 0)+5;
  137.   if LineNr<>5 then
  138.   begin
  139.     value:=HTMLRemove(Page.GetString(LineNr));
  140.     SetField(fieldLength, value);
  141.   end;
  142.  
  143.   LineNr := FindLine('<b>ESTUDIO</b>', Page, 0)+4;
  144.   if LineNr<>4 then
  145.   begin
  146.     value:=HTMLRemove(Page.GetString(LineNr));
  147.     SetField(fieldProducer, value);
  148.   end;
  149.  
  150.   LineNr := FindLine('<b>Sinopse:</b>', Page, 0);
  151.   if LineNr<>-1 then
  152.   begin
  153.     Value := Page.GetString(LineNr);
  154.     BeginPos := pos('/b>',value);
  155.     EndPos := pos('</f',value);
  156.     descricao:=copy(value,BeginPos+3,EndPos);
  157.     descricao:=HTMLRemove(descricao);
  158.     SetField(fieldDescription, descricao);
  159.   end;
  160.  
  161. end;
  162.  
  163.  
  164.  
  165. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): 
  166. Integer;
  167. var
  168.   i: Integer;
  169. begin
  170.   result := -1;
  171.   if StartAt < 0 then
  172.     StartAt := 0;
  173.   for i := StartAt to List.Count-1 do
  174.     if Pos(Pattern, List.GetString(i)) <> 0 then
  175.     begin
  176.       result := i;
  177.       Break;
  178.     end;
  179. end;
  180.  
  181. procedure AnalyzePage(Address: string);
  182. var
  183.   Page: TStringList;
  184.   LineNr, StartPos, EndPos: Integer;
  185.   Line: string;
  186.   x:integer;
  187.   MovieAddress, findMovieName,linedown : string;
  188.   guardar,url, nome_filme:string;
  189. begin
  190.   PickTreeClear;
  191.   Page := TStringList.Create;
  192.   Page.Text := GetPage(Address);
  193.  
  194.   if (pos('tφtulos que contΘm a palavra chave', Page.Text)>0) and (pos('Nada achado!.', Page.Text) = 0) then
  195.    begin
  196.     LineNr :=0;
  197.     repeat
  198.       LineNr := FindLine('+acha', Page, LineNr);//alterado
  199.       If LineNr >0 Then Begin
  200.         Line := Page.GetString(LineNr);
  201.         StartPos := pos('hts?+', Line)+1;
  202.         url:=(copy(line,StartPos+4,7));
  203.         StartPos := pos('+acha">', Line)+7;
  204.         EndPos := pos('</A>',Line)-1;
  205.         nome_filme := HTMLRemove(copy(Line, StartPos, EndPos-StartPos));
  206.         Line := Page.GetString(LineNr+1);
  207.         EndPos := pos('  ',Line)-1;
  208.         Line := copy(Line, 1, EndPos);
  209.         Line:=  HTMLRemove(Line);
  210.         nome_filme:=Line+' - '+nome_filme;
  211.         PickTreeAdd(nome_filme, url);
  212.         LineNr := LineNr + 1;
  213.       End;
  214.     until (LineNr<1);
  215.     if PickTreeExec(Address) then begin
  216.     AnalyzeFilmPage(Address);
  217.    end;
  218.    Page.Free;
  219.     end
  220.     else
  221.        ShowMessage('Nada achado!')
  222. end;
  223.  
  224. begin
  225.   PickListClear;
  226.   MovieName := GetField(fieldOriginalTitle);
  227.   if Input('Importar do DVDWorld', 'Escreva o nome do filme:', MovieName) 
  228. then begin
  229.   MovieName := StringReplace(MovieName, ' ', '%20');
  230.   
  231. AnalyzePage('http://dvdworld.com.br/dvdworld.hts?+search+'+MovieName+'+titulo');
  232.   end;
  233. end.
  234.  
  235.